-
Notifications
You must be signed in to change notification settings - Fork 126
[WIP, DNM] Enable exit tests on Android API level 28 and newer. #1381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…o work on Android, cut the knot)
| environment["SWT_CLOSEFROM"] = String(describing: highestFD + 1) | ||
| #elseif os(Android) | ||
| // Android does not have posix_spawn_file_actions_addclosefrom_np() nor | ||
| // closefrom(2), so we don't attempt this operation there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android has close_range (which closefrom is typically trivially implemented in terms of). See swiftlang/swift-subprocess#172
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
close_range() requires an upper bound, which we don't know. (Also setting CLOSE_RANGE_CLOEXEC is a good way to break code that opened a higher fd and doesn't want FD_CLOEXEC set.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that you pass ~0U (max int) as the upper bound, e.g. when reading SWT_CLOSEFROM, call close_range(x, ~0U) instead of closefrom(x). That is how closefrom is implemented internally on the platforms where it exists anyways -- close_range is the syscall, where the kernel can clamp the upper bound down to the actual highest open fd, while closefrom is only in libc.
|
Thanks, Jonathan, will try it and let you know. 👍 |
|
Seeing a couple build errors because of Not going to spend time fixing this given the bigger SwiftPM issue, but if you want to keep iterating, happy to build it locally for you. |
|
Thanks, I'll address those and ping you when it's ready to try again. |
…to jgrynspan/exit-tests-android
This PR enables exit tests on Android.
Checklist: